import { Controller, Post, Body, UseGuards, Get, Query, } from '@nestjs/common';
import { TypeManageService } from './type-manage.service';
import { CreateTypeManageDto } from './dto/create-type-manage.dto';
import { AuthGuard } from 'src/gurad/auth/auth.guard';

@UseGuards(AuthGuard)
@Controller('typeManage')
export class TypeManageController {
  constructor(private readonly typeManageService: TypeManageService) {}

  // 新增分类名称
  @Post('add')
  create(@Body() createTypeManageDto: CreateTypeManageDto) {
    return this.typeManageService.create(createTypeManageDto);
  }

  /**
   * 获取分类列表
   */
  @Get('query')
  queryType(
    @Query() queryInfo,
  ) {
    return this.typeManageService.queryType({
      ...queryInfo,
      currentPage: +queryInfo.currentPage,
      pageSize: +queryInfo.pageSize,
    });
  }

  /**
 * 删除分类
 */
  @Post('delete')
  delete(@Body() queryInfo) {
    return this.typeManageService.delete(queryInfo.id);
  }

  /**
   * 获取所有的分类
  */
  @Get('queryAll')
  getAll() {
    return this.typeManageService.getAll()
  }
}
